package com.copsoftware.reportes.geografico.beans;

import java.util.Iterator;
import java.util.List;

import com.copsoftware.reportes.geografico.support.BeanEncontrarPreferenciasTematicoZonal;

public class BeanListaZonal {
	String[] listaZonas;

	public String[] getLista() throws Exception {
		com.copsoftware.comun.delegates.GeometryDelegate geoDelegate = new com.copsoftware.comun.delegates.GeometryDelegate();
		List listaZona = geoDelegate.buscarZona();
		String[] listaGPolygon = new String[listaZona.size()];
		String[] listStrokeColors = new String[] { "'#faebd7'", "'#d8bfd8'",
				"'#ff7f50'", "'#98fb98'" };
		String[] listFillColors = new String[] { "'#faebd7'", "'#d8bfd8'",
				"'#ff7f50'", "'#98fb98'" };
		String[] listStrokeWeight = new String[] { "2", "2", "2", "2" };
		String[] listStrokeOpacity = new String[] { "1", "1", "1", "1" };
		String[] listFillOpacity = new String[] { "0.2", "0.2", "0.2", "0.2" };
		
		int i = 0;
		for (Iterator iter = listaZona.iterator(); iter.hasNext(); i++) {
			com.copsoftware.entity.GeoZonaImpl element = (com.copsoftware.entity.GeoZonaImpl) iter.next();
			com.vividsolutions.jts.geom.Geometry geo = element.getGLimite();
			String wkt = geo.toString();
			listaGPolygon[i] = com.copsoftware.utils.beans.GeoUtils
					.obtenerGPolygon(wkt)
					+ listStrokeColors[i]
					+ ","
					+ listStrokeWeight[i]
					+ ","
					+ listStrokeOpacity[i]
					+ ","
					+ listFillColors[i]
					+ ","
					+ listFillOpacity[i] + ")";
		}
		java.lang.System.out.println(listaGPolygon[0]);
		java.lang.System.out.println(listaGPolygon[1]);
		java.lang.System.out.println(listaGPolygon[2]);
		java.lang.System.out.println(listaGPolygon[3]);
		return listaGPolygon;
	}

	public String getPruebaSetParameters(String [] lista)
	{
		return "Lista enviada: "+lista[0]+","+lista[1]+","+lista[2];
	}
	public void setLista(String[] lista) {
		this.listaZonas = lista;
	}
	
	
	public String[] getListaTematicoZonal(String [] listaJSONString) throws Exception {
		com.copsoftware.comun.delegates.GeometryDelegate geoDelegate = new com.copsoftware.comun.delegates.GeometryDelegate();
		List listaZona = geoDelegate.buscarZona();
		String[] listaGPolygon = new String[listaZona.size()];
		String[] listStrokeColors = new String[] { "'#faebd7'", "'#d8bfd8'",
				"'#ff7f50'", "'#98fb98'" };
		String[] listFillColors = new String[] { "'#faebd7'", "'#d8bfd8'",
				"'#ff7f50'", "'#98fb98'" };
		String[] listStrokeWeight = new String[] { "2", "2", "2", "2" };
		String[] listStrokeOpacity = new String[] { "1", "1", "1", "1" };
		String[] listFillOpacity = new String[] { "0.2", "0.2", "0.2", "0.2" };
		
		//TODO Reubicar el metodo crearBeanTematicoZonal
		List listaJSONOBjects = BeanTematicoZonal.crearBeanTematicoZonal(listaJSONString);;
		
		
		
		int i = 0;
		
		//TODO Hacerlo dinamico, query devuelve BeanZona con GLimite y numMaxTipoDelito
		
		int [] listNumMaxTipoDelito = new int [] {5,5,5,5,5};
		for (Iterator iter = listaZona.iterator(); iter.hasNext(); i++) {
			com.copsoftware.entity.GeoZonaImpl element = (com.copsoftware.entity.GeoZonaImpl) iter.next();
			com.vividsolutions.jts.geom.Geometry geo = element.getGLimite();
			BeanZona bnZona = new BeanZona();
			bnZona.setGLimite(geo);
			bnZona.setNumMaxTipoDelito(listNumMaxTipoDelito[i]);
			String wkt = geo.toString();
			listaGPolygon[i] = com.copsoftware.utils.beans.GeoUtils
					.obtenerGPolygon(wkt)
					+ BeanEncontrarPreferenciasTematicoZonal.getPreferencia(listaJSONOBjects,BeanTematicoZonal.STROKE_COLOR,bnZona)
					+ ","
					+ BeanEncontrarPreferenciasTematicoZonal.getPreferencia(listaJSONOBjects,BeanTematicoZonal.STROKE_WEIGTH,bnZona)
					+ ","
					+ BeanEncontrarPreferenciasTematicoZonal.getPreferencia(listaJSONOBjects,BeanTematicoZonal.STROKE_OPACITY,bnZona)
					+ ","
					+ BeanEncontrarPreferenciasTematicoZonal.getPreferencia(listaJSONOBjects,BeanTematicoZonal.FILL_COLOR,bnZona)
					+ ","
					+ BeanEncontrarPreferenciasTematicoZonal.getPreferencia(listaJSONOBjects,BeanTematicoZonal.FILL_OPACITY,bnZona) + ")";
		}
		java.lang.System.out.println(listaGPolygon[0]);
		java.lang.System.out.println(listaGPolygon[1]);
		java.lang.System.out.println(listaGPolygon[2]);
		java.lang.System.out.println(listaGPolygon[3]);
		return listaGPolygon;
	}	

	public static void main(String[] args) {

	}
}
